import {Redirect, Route} from 'react-router-dom'

export default function AuthRout({Component,...rest}){
   

    return (
        <Route {...rest} render={props=>{
            if(localStorage.getItem('token')){
                return <Component {...rest}></Component>
            }else{
                return <Redirect to={{pathname:"/login",state:{
                    from:props.location
                }}}></Redirect>
            }
        }}></Route>
    )
}